Skip to content

Conversation

@aladerran
Copy link
Contributor

@aladerran aladerran commented Jul 11, 2025

Essential Elements of an Effective PR Description Checklist

  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Purpose

In response to #20468, add EPLB support for Qwen3-fp8 model.

Test Plan

Running CUDA_VISIBLE_DEVICES=0,1,2,3 python path_to_this_script.py

# SPDX-License-Identifier: Apache-2.0  
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project  
  
from vllm import LLM, SamplingParams  
  
# Sample prompts.  
prompts = [  
    "Hello, my name is",  
    "The president of the United States is",  
    "The capital of France is",  
    "The future of AI is",  
]  
# Create a sampling params object.  
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)  
  
  
def main():  
    # Create an LLM with EPLB parameters.  
    llm = LLM(  
        model="Qwen/Qwen3-235B-A22B-FP8",
        tensor_parallel_size=4,
        enable_expert_parallel=True,  
        enable_eplb=True,  
        num_redundant_experts=32,  
        eplb_window_size=1000,  
        eplb_step_interval=3000,
        trust_remote_code=True,
        enforce_eager=True,
    )  
    # Generate texts from the prompts.  
    # The output is a list of RequestOutput objects  
    # that contain the prompt, generated text, and other information.  
    outputs = llm.generate(prompts, sampling_params)  
    # Print the outputs.  
    print("\nGenerated Outputs:\n" + "-" * 60)  
    for output in outputs:  
        prompt = output.prompt  
        generated_text = output.outputs[0].text  
        print(f"Prompt:    {prompt!r}")  
        print(f"Output:    {generated_text!r}")  
        print("-" * 60)  
  
  
if __name__ == "__main__":  
    main()

Test Result

...

^[[1;36m(VllmWorker rank=0 pid=91414)^[[0;0m INFO 07-11 11:56:57 [eplb_state.py:353] Rearranging experts (profile)...
^[[1;36m(VllmWorker rank=0 pid=91414)^[[0;0m INFO 07-11 11:57:03 [eplb_state.py:428] Rearranged experts (profile) in 5.19 seconds.
^[[1;36m(VllmWorker rank=0 pid=91414)^[[0;0m INFO 07-11 11:57:07 [gpu_worker.py:241] Available KV cache memory: 7.62 GiB
^[[1;36m(VllmWorker rank=2 pid=91416)^[[0;0m INFO 07-11 11:57:07 [gpu_worker.py:241] Available KV cache memory: 7.44 GiB
^[[1;36m(VllmWorker rank=3 pid=91417)^[[0;0m INFO 07-11 11:57:07 [gpu_worker.py:241] Available KV cache memory: 8.37 GiB
^[[1;36m(VllmWorker rank=1 pid=91415)^[[0;0m INFO 07-11 11:57:07 [gpu_worker.py:241] Available KV cache memory: 7.44 GiB
INFO 07-11 11:57:08 [kv_cache_utils.py:716] GPU KV cache size: 170,064 tokens
INFO 07-11 11:57:08 [kv_cache_utils.py:720] Maximum concurrency for 40,960 tokens per request: 4.15x
INFO 07-11 11:57:08 [kv_cache_utils.py:716] GPU KV cache size: 165,872 tokens
INFO 07-11 11:57:08 [kv_cache_utils.py:720] Maximum concurrency for 40,960 tokens per request: 4.05x
INFO 07-11 11:57:08 [kv_cache_utils.py:716] GPU KV cache size: 165,872 tokens
INFO 07-11 11:57:08 [kv_cache_utils.py:720] Maximum concurrency for 40,960 tokens per request: 4.05x
INFO 07-11 11:57:08 [kv_cache_utils.py:716] GPU KV cache size: 186,784 tokens
INFO 07-11 11:57:08 [kv_cache_utils.py:720] Maximum concurrency for 40,960 tokens per request: 4.56x
INFO 07-11 11:57:10 [core.py:172] init engine (profile, create kv cache, warmup model) took 19.07 seconds

Generated Outputs:
------------------------------------------------------------
Prompt:    'Hello, my name is'
Output:    " Alex. I'm 13 years old. I'm from Canada. I"
------------------------------------------------------------
Prompt:    'The president of the United States is'
Output:    ' the head of state and head of government of the United States, indirectly elected to'
------------------------------------------------------------
Prompt:    'The capital of France is'
Output:    ' Paris. The capital of Poland is Warsaw. The capital of Germany is Berlin.'
------------------------------------------------------------
Prompt:    'The future of AI is'
Output:    ' collaborative\n\nThe future of AI is collaborative\n\nWhile artificial intelligence (AI) has'
------------------------------------------------------------

(Optional) Documentation Update

@github-actions
Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added the qwen Related to Qwen models label Jul 11, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @aladerran, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces EPLB support for the Qwen3 model, enhancing its performance and scalability. The changes primarily focus on integrating EPLB into the model's MoE layers and adjusting the weight loading process to handle expert-specific weights. The test plan includes running a script to verify the functionality, and the test results show successful execution with EPLB enabled.

Highlights

  • EPLB Support: Adds Expert Parallel Load Balancing (EPLB) support for the Qwen3 model, addressing issue #20468.
  • FusedMoE Integration: Integrates EPLB functionality into the FusedMoE layer, including handling of redundant experts and expert mapping.
  • Weight Loading: Modifies weight loading logic to accommodate expert weights and ensure correct mapping of weights to experts.
  • Model Configuration: Adds configuration options for enabling EPLB and setting the number of redundant experts.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds EPLB support for the Qwen3 MoE model. The changes propagate EPLB configurations and update the weight loading logic to handle redundant experts. The implementation of the MixtureOfExperts interface is also mostly complete. I've added one comment to ensure full compliance with the interface protocol.

@mergify
Copy link

mergify bot commented Jul 15, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @aladerran.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Jul 15, 2025
@mergify mergify bot removed the needs-rebase label Jul 16, 2025
@aladerran aladerran force-pushed the eplb_for_qwen3 branch 2 times, most recently from 913c81e to 05191c3 Compare July 16, 2025 01:54
@mergify
Copy link

mergify bot commented Jul 18, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @aladerran.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@aladerran
Copy link
Contributor Author

aladerran commented Jul 22, 2025

Hi @abmfy, @DarkLight1337

I’ve completed testing and rebased the PR onto the latest base branch.
Could you take a look when you have some time?

Thank you!

@aladerran aladerran force-pushed the eplb_for_qwen3 branch 5 times, most recently from 97768a6 to 5f928b4 Compare July 23, 2025 14:50
Signed-off-by: aladerran <aladerran@gmail.com>
@abmfy
Copy link
Member

abmfy commented Jul 23, 2025

Hi @abmfy, @DarkLight1337

I’ve completed testing and rebased the PR onto the latest base branch. Could you take a look when you have some time?

Thank you!

Sure—really appreciate the contributions! I just got back from traveling and will review it soon. Sorry for the delay!


params_dict = dict(self.named_parameters())
loaded_params: set[str] = set()
expert_params_mapping = self.get_expert_mapping()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line overrides the previous expert_params_mapping binding. I suggest refactoring lines L435–L442 into the get_expert_mapping method.

Additionally, since the current weight loading process does not account for redundant experts, I suspect there might be some issues in the weight loading logic. I’ll run some accuracy tests to verify.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored, any suggestion or help needed for verifying weight loading process?

# Skip loading extra parameters for GPTQ/modelopt models.
if name.endswith(
if name_mapped.endswith(
ignore_suffixes) and name not in params_dict:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should modify name to name_mapped in this line?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally, this function assumes that name will be directly replaced in place. However, since we’re now creating a new variable, should we update the usage of name here to name_mapped instead?
(It looks like the change might have gone in the opposite direction)

Copy link
Contributor Author

@aladerran aladerran Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I guess I rushed through. Thanks for pointing it out.

Resolved.

@aladerran
Copy link
Contributor Author

@abmfy Thanks for the review! Will respond tonight.

@aladerran aladerran requested a review from abmfy July 24, 2025 14:26
@DarkLight1337 DarkLight1337 added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 29, 2025
Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, tests will be added in #21290

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) July 29, 2025 13:33
@aladerran
Copy link
Contributor Author

@DarkLight1337 Thanks for the heads-up. I'll follow up on https://github.com/vllm-project/vllm/pull/21290 .

By the way, I checked the CI logs, and it seems the failure isn't caused by this PR.

@david6666666
Copy link
Contributor

david6666666 commented Jul 30, 2025

@DarkLight1337 Thanks for the heads-up. I'll follow up on https://github.com/vllm-project/vllm/pull/21290 .

By the way, I checked the CI logs, and it seems the failure isn't caused by this PR.

@aladerran thanks for your reply.And we will add test later #21290

@aladerran aladerran requested a review from DarkLight1337 July 30, 2025 10:41
@vllm-bot vllm-bot merged commit d979dd6 into vllm-project:main Jul 30, 2025
75 of 78 checks passed
@Ruihan11
Copy link

nice

@Irving11-BKN
Copy link

nice done

liuyumoye pushed a commit to liuyumoye/vllm that referenced this pull request Jul 31, 2025
Signed-off-by: aladerran <aladerran@gmail.com>
vadiklyutiy pushed a commit to CentML/vllm that referenced this pull request Aug 5, 2025
Signed-off-by: aladerran <aladerran@gmail.com>
x22x22 pushed a commit to x22x22/vllm that referenced this pull request Aug 5, 2025
Signed-off-by: aladerran <aladerran@gmail.com>
Signed-off-by: x22x22 <wadeking@qq.com>
npanpaliya pushed a commit to odh-on-pz/vllm-upstream that referenced this pull request Aug 6, 2025
Signed-off-by: aladerran <aladerran@gmail.com>
jinzhen-lin pushed a commit to jinzhen-lin/vllm that referenced this pull request Aug 9, 2025
Signed-off-by: aladerran <aladerran@gmail.com>
Signed-off-by: Jinzhen Lin <linjinzhen@hotmail.com>
noamgat pushed a commit to noamgat/vllm that referenced this pull request Aug 9, 2025
Signed-off-by: aladerran <aladerran@gmail.com>
Signed-off-by: Noam Gat <noamgat@gmail.com>
paulpak58 pushed a commit to paulpak58/vllm that referenced this pull request Aug 13, 2025
Signed-off-by: aladerran <aladerran@gmail.com>
Signed-off-by: Paul Pak <paulpak58@gmail.com>
diegocastanibm pushed a commit to diegocastanibm/vllm that referenced this pull request Aug 15, 2025
Signed-off-by: aladerran <aladerran@gmail.com>
Signed-off-by: Diego-Castan <diego.castan@ibm.com>
@koush
Copy link

koush commented Aug 21, 2025

@mgoin @aladerran this change caused a regression in loading qwen3 coder 480b. there's a key error with 'layers.23.mlp.gate.weight' while loading the model. Investigating further. There is a key 'layers.23.mlp.gate.qweight'.

@mgoin
Copy link
Member

mgoin commented Aug 21, 2025

Thanks for reporting @koush, would you mind opening an issue so we can track for the upcoming release?

epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: aladerran <aladerran@gmail.com>
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
Signed-off-by: aladerran <aladerran@gmail.com>
@aladerran aladerran deleted the eplb_for_qwen3 branch October 24, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

qwen Related to Qwen models ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants